import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'layout',
    component: () => import(/* webpackChunkName: "introduce" */ '@/views/Layout/layout.vue'),
    redirect: '/Home',
    children: [
      {
        path: 'Home', // 为空表示默认子路由
        name: 'home',
        component: () => import(/* webpackChunkName: "introduce" */ '@/views/Home/home.vue')
      },
      {
        path: 'Qa',
        name: 'qa',
        component: () => import(/* webpackChunkName: "introduce" */ '@/views/Qa/qa.vue')
      },
      {
        path: 'Video',
        name: 'video',
        component: () => import(/* webpackChunkName: "introduce" */ '@/views/Video/video.vue')
      },
      {
        path: 'My',
        name: 'my',
        component: () => import(/* webpackChunkName: "introduce" */ '@/views/My/my.vue')
      }],
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/Login',
    name: 'login',
    component: () => import(/* webpackChunkName: "introduce" */ '@/views/Login/login.vue')
  },
  {
    path: '/Search',
    name: 'search',
    component: () => import(/* webpackChunkName: "introduce" */ '@/views/Search/search.vue')
  },
  {
    path: '/Aticle/:aticleId',
    name: 'aticle',
    component: () => import(/* webpackChunkName: "introduce" */ '@/views/Aticle/aticle.vue'),
    props: true, // 开启props传参，把路由参数映射到组件的props中
    meta: {
      keepAlive: true
    }
  },
  {
    path: '/profile',
    name: 'myProfile',
    component: () => import(/* webpackChunkName: "introduce" */ '@/views/My/myProfile.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
